70) { heightAdj = "tall" grade += 2 } else if (height < 30) { heightAdj = "short" grade += 1 } else { heightAdj = "medium-height" grade += 3 } if (propWeight > 2) { weightAdj = "over-weight" grade += 1 } else if (propWeight < 0.5) { weightAdj = "slim" grade += 2 } else { weightAdj = "medium-weight" grade += 3 } ageAdj = ageInput + "-year old" if (grade >= 5) gradeAdj = "great-looking" else if (grade <= 2) gradeAdj = "ackward-looking" else gradeAdj = "fine-looking" sexAdj = (sex == "f") ? "female" : "male" var finalMessage = "You are a " + heightAdj + ", " finalMessage += weightAdj + ", " + gradeAdj + " " finalMessage += ageAdj + " " + sexAdj + "." alert(finalMessage) if (confirm("Are you interested in scientific results?")) { scMessage = "height = " + Math.round(height) scMessage +="%\rweight = " + Math.round(weight) scMessage += "%\rweight/height = " + propWeight alert(scMessage) } else if (grade <= 4) alert("Good idea!") var notice = "Thank you for using the JavaScript weight " notice += "and height calculator. All calculations are " notice += "done according to the child-development graph " notice += "in \"Compton's Encyclopedia\". We appologize " notice += "if you were insulted by the comments">



Home } Calculators } Body



I like this script because it uses some very ingenious JavaScripting techniques. into the process, it analyzses a persons information (sex, height, weight) and responds with a comment message.

JavaScript Source Code 2002: Calculator: Body Calculator

Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!!